'use strict';

const path = require('path');
const { getBaseDir } = require('ee-core/ps');
const ElectronBootstrap = require('../index');

/**
 * 默认配置
 */
module.exports = () => {
  // 初始化 Electron 相关功能
  new ElectronBootstrap();

  const config = {
    openDevTools: true,
    singleLock: true,
    windowsOption: {
      title: '智考导师',
      width: 420,
      height: 800,
      minWidth: 420,
      minHeight: 800,
      webPreferences: {
        webSecurity: false,
        contextIsolation: false,
        nodeIntegration: true,
      },
      frame: true,
      show: true,
      icon: path.join(getBaseDir(), 'public', 'images', 'logo-32.png'),
    },
    logger: {
      level: 'INFO',
      outputJSON: false,
      appLogName: 'ee.log',
      coreLogName: 'ee-core.log',
      errorLogName: 'ee-error.log' 
    },
    remote: {
      enable: true,
      url: 'https://tutor.lics.asia'
    },
    socketServer: {
      enable: false,
      port: 7070,
      path: "/socket.io/",
      connectTimeout: 45000,
      pingTimeout: 30000,
      pingInterval: 25000,
      maxHttpBufferSize: 1e8,
      transports: ["polling", "websocket"],
      cors: {
        origin: true,
      },
      channel: 'socket-channel'
    },
    httpServer: {
      enable: false,
      https: {
        enable: false, 
        key: '/public/ssl/localhost+1.key',
        cert: '/public/ssl/localhost+1.pem'
      },
      host: '127.0.0.1',
      port: 7071,
    },
    mainServer: {
      indexPath: '/public/dist/index.html',
      channelSeparator: '/',
    },
    lifecycle: {
      async ready() {
        console.log('注册快捷键...');
      },

      async beforeClose() {
        console.log('注销快捷键...');
      }
    }
  }

  // 添加快捷键配置
  config.shortcut = {
    key: 'CommandOrControl+Alt+I',  // 使用一个不太容易冲突的快捷键组合
    enable: true
  }

  // 添加生命周期配置
  config.autoLaunch = {
    enable: true,
  }

  return config;
}
